package com.mypack.action;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.mypack.business.User;
import com.mypack.manager.UserManager;

@Controller
public class UserController {
	
	@Autowired
	private UserManager userManager;
	
	@RequestMapping("/index")
	public void index(){
		
		User user = new User();
		user.setName("cz");
		user.setAge(12);
		user.setSellerId(2434L);
		Long pk = userManager.saveUser(user);
		
		user.setId(pk);
		User getUser = userManager.getUser(user);
		System.out.println("**************"+getUser);
		
		
	    List<User> users = userManager.queryUser(getUser);
		System.out.println("##############" + users.size() + "&&&&&&&&&&&&&&&&&&&" + users);
		
		
		List<User> usersCompiledSQL = userManager.queryUserByCompiledSQL(getUser);
		System.out.println("eeeeeeeeeeeeeee" + usersCompiledSQL.size() + "xxxxxxxxxxxxxxxxxxxxx" + usersCompiledSQL);
		
				
	}
	
	@RequestMapping("/index1")
	public void testTrans(){
		User user = new User();
		user.setName("cz");
		user.setAge(12);
		user.setSellerId(1L);
		userManager.saveUserTrans(user);
	}
}
